package neu.edu.cn.nuemall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import neu.edu.cn.nuemall.entity.Publish;
import neu.edu.cn.nuemall.mapper.PublishMapper;
import neu.edu.cn.nuemall.service.PublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PublishServiceImpl implements PublishService {

    @Autowired
    private PublishMapper publishMapper;

    @Override
    public PageInfo<Publish> listLatesPublishs(Integer page, Integer count) {
        PageHelper.startPage(page,count);
        QueryWrapper<Publish> queryWrapper=new QueryWrapper<Publish>();
        queryWrapper.orderByDesc("create_at");

        List<Publish> publishList= publishMapper.selectList(queryWrapper);
        PageInfo<Publish> pageInfo=new PageInfo<Publish>(publishList);
        return pageInfo;
    }

    @Override
    public Publish getPublishById(String publishid) {
        Publish publish= publishMapper.selectById(publishid);
        return publish;
    }
}
